##########################################################################################

library(dplyr)
library(data.table)
library(optparse)

##########################################################################################

option_list <- list(
    make_option(c("--info_file"), type = "character") ,
    make_option(c("--out_file"), type = "character")
)

if(1!=1){
    
    work_dir <- "~/20220915_gastric_multiple/dna_combine/"
	info_file <- paste(work_dir,"/config/tumor_normal.class.list",sep="")
    out_file <- paste(work_dir,"/tree/tumor_normal.class.forTree.list",sep="")

}

###########################################################################################

parseobj <- OptionParser(option_list=option_list, usage = "usage: Rscript %prog [options]")
opt <- parse_args(parseobj)
print(opt)

info_file <- opt$info_file
out_file <- opt$out_file

##########################################################################################

dat_info <- data.frame(fread(info_file))
sampleNum <- dat_info %>%
group_by( ID ) %>%
summarize( SampleNum = length(Tumor) )

dat_info <- merge( dat_info , sampleNum )

write.table( dat_info , out_file , row.names = F , sep = "\t" , quote = F )